#include "agentstat.h"
#include "agentsocket.h"
#include "sockets/SocketHandler.h"
#include "sockets/ListenSocket.h"
#include <iostream>
#include <fstream>


using namespace std;

AgentStat::AgentStat() : m_data(0), m_config(0)
{
        m_data = new Data();
        m_config = new CfgParser(0);
        m_disk_array = new std::map < std::string, bool>;
        m_data->setDiskArray(m_disk_array);
        m_data->setConfig(m_config);
}

AgentStat::~AgentStat()
{
        delete m_data;
        delete m_disk_array;
}

void AgentStat::listen()
{
        SocketHandler h;
        ListenSocket<AgentSocket> l(h, m_data);
        if (l.Bind(11000))
        {
                exit(-1);
        }
        h.Add(&l);
        h.Select(1, 0);
        while (h.GetCount())
        {
                h.Select(1, 0);
        }
}
